﻿using Application.Dto;
using AutoMapper;
using Domain.Entity;
using Domain.Repository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Application.AppService
{
	public class UserAppService : IUserAppService
	{
		//      private readonly IMapper mapper;

		//      public IUserRepository UserRepository { get; set; }
		//      public UserAppService(IUserRepository userRepository)
		//{
		//          UserRepository = userRepository;
		//          this.mapper = mapper;
		//}

		//      public bool UserDelete(UserSelectDto userSelectDto)
		//      {
		//          User user = mapper.Map<User>(userSelectDto);
		//          return UserRepository.UserDelete(user);
		//      }
		//      public bool UserAdd(UserSelectDto userSelectDto)
		//      {
		//          User user = mapper.Map<User>(userSelectDto);
		//          return UserRepository.UserAdd(user);
		//      }
		//      public List<User> UserGet()
		//      {
		//         return UserRepository.UserGet();
		//      }

		//      public List<User> UserSelect(UserSelectDto userSelectDto)
		//      {
		//          User user = mapper.Map<User>(userSelectDto);
		//          return UserRepository.SelectUser(user);
		//      }

		//      public bool UserUpdate(UserSelectDto userSelectDto)
		//      {
		//          User user = mapper.Map<User>(userSelectDto);
		//          return UserRepository.UserUpdate(user);
		//      }

		//public List<Trees2> trees(string id)
		//{
		//	return UserRepository.trees(id);
		//}

		//public List<Jurisdiction> trees2()
		//{
		//          return UserRepository.trees2();
		//}
		private readonly IMapper mapper;

		public IUserRepository UserRepository { get; set; }

		public UserAppService(IUserRepository userRepository, IMapper mapper)
		{
			UserRepository = userRepository;
			this.mapper = mapper;
		}

		public List<User> UserSelect(UserSelectDto userSelectDto)
		{
			User user = mapper.Map<User>(userSelectDto);
			return UserRepository.SelectUser(user);
		}

		public List<User> UserGet()
		{
			return UserRepository.UserGet();
		}

		public bool UserDelete(UserSelectDto userSelectDto)
		{
			User user = mapper.Map<User>(userSelectDto);
			return UserRepository.UserDelete(user);
		}

		public bool UserUpdate(UserSelectDto userSelectDto)
		{
			User user = mapper.Map<User>(userSelectDto);
			return UserRepository.UserUpdate(user);
		}
		public List<CPC> GetName(CPCDto cPCDto)
		{
			CPC cPC = mapper.Map<CPC>(cPCDto);
			return UserRepository.GetName(cPC);
		}

		public List<User> GetUsers(int id)
		{

			return UserRepository.GetUsers(id);
		}

		public bool UserAdd(UserSelectDto userSelectDto)
		{
			User user = mapper.Map<User>(userSelectDto);
			return UserRepository.UserAdd(user);
		}

		public List<Roles> RolesSelect()
		{
			return UserRepository.RolesSelect();
		}

		public bool AddRoles(RolesDto roles)
		{
			Roles user = mapper.Map<Roles>(roles);
			return UserRepository.AddRoles(user);
		}

		public bool DeleteRoles(int id)
		{
			return UserRepository.DeleteRoles(id);
		}


		public List<Trees2> trees(string id)
		{
			return UserRepository.trees(id);
		}

		public async Task<List<Jurisdiction>> JurisdictionList()
		{
			return await UserRepository.JurisdictionList();
		}

		public List<Jurisdiction> trees2()
		{
			return UserRepository.trees2();
		}

		public Task<List<int>> selectRolesJurisdiction(int id)
		{
			return UserRepository.selectRolesJurisdiction(id);
		}

		public List<Roles> Shwo(int id)
		{
			return UserRepository.Shwo(id);
		}

		public bool UpdateRole(string RolesName, string RolesInstruction, int RolesIf, string JuriID, int RolesID)
		{
			return UserRepository.UpdateRole(RolesName, RolesInstruction, RolesIf, JuriID, RolesID);
		}
	}
}
